package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("userShopController")
@RequestMapping("/user/shop")
@Api(tags = "店铺状态管理")
@Slf4j
public class Shopcontroller {

    public static final String SHOP_STATUS = "SHOP_STATUS";
    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 用户端查询营业状态
     */
    @GetMapping("/{status}")
    @ApiOperation("管理端查询营业状态")
    public Result getStatus() {
        log.info("查询店铺的营业状态");
        Integer status = (Integer) redisTemplate.opsForValue().get(SHOP_STATUS);
        log.info("店铺的营业状态为 " + status);
        if (status == null){
            return Result.error("查询失败");
        }
        return Result.success(status);
    }


}
